var url = "http://47.108.197.28:4000/api/article";
var xhr = new XMLHttpRequest();
xhr.open("GET",url,true);
xhr.send();
xhr.onreadystatechange = function(){
    if(xhr.readyState === 4){
        if(xhr.status >= 200 && xhr.status < 300){
            var res = JSON.parse(xhr.response).res;
            console.log(res)
            res.forEach(item=>{
                var {title,content,imgSrc,date,avatar,collectNum,reading} = item;
                var temple = `
                    <div class="item">
                        <div class="author">
                            <img src="${avatar}" alt="">
                            <p class="data">${date}</p>
                        </div>
                        <p class="title">${title}</p>
                        <img src="${imgSrc}" alt="">
                        <p class="detail">${content}</p>
                        <div class="commentary">
                            <p>${collectNum}</p>
                            <p>${reading}</p>
                        </div>
                    </div>
                `
                $("#container").append(temple);
            })
        }
    }
}